<template>
  <el-dialog title="伪线索上报" :visible.sync="open" append-to-body>
    <el-form ref="form" :rules="rules" :model="form" label-width="80px">
      <el-row>
        <el-col :span="24">
          <el-form-item label="原因" prop="falseReason">
            <el-select v-model="form.falseReason" placeholder="请选择原因">
              <el-option v-for="dict in dict.type.reasons_for_reporting" :label="dict.label" :value="dict.value" :key="dict.value"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="备注" prop="record">
            <el-input type="textarea" v-model="form.record"/>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="open = false">取 消</el-button>
      <el-button type="primary" @click="submitForm">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
  import { fakeClue } from "@/api/crm/clueTrack";
    export default {
        name: "false-clue",
      dicts: ['reasons_for_reporting'],
      props: ['clueId'],
      data() {
          return {
            open: false,
            form: {
              id: null,
              clueId: null,
              falseReason: null,
              record: null,
            },
            rules: {
              reason: [
                { required: true, message: "原因不能为空", trigger: "change" }
              ],
              record: [
                { required: true, message: "备注不能为空", trigger: "blur" }
              ],
            },
          }
      },
      methods: {
          submitForm() {
            this.$refs.form.validate(valid => {
              if (valid) {
                this.form.id = this.clueId;
                this.form.clueId = this.clueId;
                fakeClue(this.clueId, this.form).then(() => {
                    this.$modal.msgSuccess('操作成功');
                    this.$emit('success')
                })
                this.open = false;
              }
            })
          },
          resetForm() {
            this.form = {
                id: null,
                clueId: null,
                falseReason: null,
                record: null,
            }
          },
      }
    }
</script>

<style scoped>

</style>
